function fn() {
    let arr = [];
    let n = prompt(`输入层高：`);
    for (let i = 0; i < n; i++) {
        arr.length = 0;
        for (let j = 0; j < n - i - 1; j++) {
            arr.unshift(`<div></div>`);
            let s = arr[j];
            document.write(`${s}`);
        }
        arr.length = 0;
        for (let m = 0; m < i * 2 + 1; m++) {
            //为偶数时输出* 奇数输出空格
            if (m % 2 === 0) {
                arr.push(`<div>*</div>`);
            } else {
                arr.push(`<div></div>`);
            }
            let b = arr[m];
            document.write(`${b}`);
        }
        document.write(`</br>`);
    }
}
fn();